<?php
	if(!defined('BASEPATH'))
		exit('No direct script access allowed');

	class m_EditVendors extends CI_Model
	{
		function __construct()
    	{
    	    // Call the Model constructor
    	    parent::__construct();
    	}
		
		function get_vendors($userid)
		{
			$this->load->database();
			$this->load->library('Datatables'); 
			$this->datatables->select('tblVendorNames.Vendor_Name, tblVendorAddresses.Street_Address, tblVendorAddresses.City, tblVendorAddresses.State, tblVendorAddresses.Zip_Code, tblVendorNames.Vendor_Website, tblVendorNames.Vendor_ID')->from('tblVendorNames')->join('tblVendorAddresses', 'tblVendorNames.Vendor_ID = tblVendorAddresses.Vendor_ID')->join('tblVendorLinks', 'tblVendorLinks.Vendor_ID = tblVendorNames.Vendor_ID')->where('tblVendorLinks.userId', $userid);
			$query = $this->datatables->generate();
			return $query;
		}

		function get_user_id($userEmail)
    	{
			$this->load->database();
			$this->db->select('userId')->from('tblUser')->where('userEmail', $userEmail);
			$query = $this->db->get();
			return $query;
    	}
		
		function deletelink($userId, $Vendor_ID)
    	{
			$this->load->database();
			$this->db->delete('tblVendorLinks', array('userId' => $userId, 'Vendor_ID' => $Vendor_ID));
    	}
		
		function deletebills($userId, $Vendor_ID)
    	{
			$this->load->database();
			$this->db->delete('tblBills', array('userId' => $userId, 'Vendor_ID' => $Vendor_ID));
    	}
	}
?>
